<?php
class SubCates extends CWidget
{
	public $cid;

	public function run(){
		$criteria = new CDbCriteria();
		$criteria->condition = 'parent_cid=:pid';
		$criteria->order = 'name asc';
		$criteria->params = array(':pid'=>$this->cid);
		$data = Cates::model()->findAll($criteria);
		if(count($data) <1) $data[]=Cates::model()->find('cid=:cid',array(':cid'=>$this->cid));
		$subcates = '';
		foreach($data as $d){
			$subcates .= CHtml::link($d->name,array('/item/list','cid'=>$d->cid),array('title'=>$d->name));
		}
		echo $subcates;
	}
}